<cfapplication name="cacheManagementExamples" sessionmanagement="true" />

<cfif !structKeyExists( application, 'cache' ) or structKeyExists( url, 'init' ) >
	
	<cfset xml = expandPath( "/cacheManagement/examples/config/cache.xml" )>
	
	<cfdirectory action="list" directory="#expandPath( '/cacheManagement/examples/root/' )#" name="dir" />

	<cfquery dbtype="query" name="dir">
	select *
	from dir
	where type = 'Dir'
	and name <> '.svn'
	</cfquery>

	<cflock scope="Application" timeout="10" type="exclusive">

		<cfset application.cache = createObject( 'component', 'cacheManagement.CacheManager' ).init( xml ) />	
	
		<cfset application.factory = createObject( 'component', 'cacheManagement.examples.util.Factory' ).init() />
	
		<cfset application.examples = dir />
		
		<cfset application.facade = createObject( 'component', 'cacheManagement.examples.util.SessionManager' ).init() />
	
	</cflock>

</cfif>

<cffunction name="getCacheManager" returntype="cacheManagement.CacheManager" >
	<cfreturn application.cache />
</cffunction>

<cffunction name="getFactory" returntype="cacheManagement.examples.util.Factory">
	<cfreturn application.factory />
</cffunction>

<cffunction name="getExamples" returntype="Query">
	<cfreturn application.examples />
</cffunction>

<cffunction name="getFacade" returntype="cacheManagement.examples.util.SessionManager">
	<cfreturn application.facade />
</cffunction>

<cffunction name="getListener" returntype="cacheManagement.examples.root.event.Event">
	<cfreturn createObject( 'component', 'cacheManagement.examples.root.event.Event' ).init( getFacade() )/>
</cffunction>